<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="layout" content="wechat"/>
    <title>免费评房11</title>
</head>

<body>
<header class="create-header">
        <ul class="creat-flowList flex-box">
            <li data-id="01" class="flex1 active">
                <span></span>
                <h3>小区信息</h3>
            </li>
            <li data-id="02" class="flex1">
                <span></span>
                <h3>房产信息</h3>
            </li>
            <li data-id="03" class="flex1">
                <span></span>
                <h3>极速估值</h3>
            </li>
        </ul>
</header>

<div class="wxAutoCreat">
    <form action="wxCreate2Step2" id="wxCreate2Form1" method="post" class="wxCreate2Form1">
        <input type="hidden" name="openId" value="${this.leads?.openId}"/>
        <div class="bgcWhite wxCreate weui-cells weui-cells_form">
            <div class="weui-cell weui-cell_select weui-cell_select-after">
                <div class="weui-cell__hd"><label class="weui-label">所在城市</label></div>
                <div class="weui-cell__bd weui-cell_primary">
                    <g:select class="weui-select" name="city" id="city" optionKey="id" optionValue="name" from="${this.cityList}" value="${this.leads?.city?.name}"/>
                </div>
            </div>

            <div class="weui-cell weui-cell_select weui-cell_select-after">
                <div class="weui-cell__hd"><label class="weui-label">所在区县</label></div>

                <div class="weui-cell__bd weui-cell_primary">
                    <select class="weui-select" name="district" id="district">
                    </select>
                </div>
            </div>

            <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">小区名称</label></div>
                <div class="weui-cell__bd weui-cell_primary">
                    <g:textField class="weui-input" type="text" id="projectName" name="projectName" value="${this.leads.projectName}" placeholder="如：花家地西里一区" autocomplete="off"/>
                </div>
            </div>
        </div>

        <div class="bigBtn">
            <button type="button" class="linkBtn weui-btn weui-btn_plain_default" id="wxcreateStep1Btn">下一步</button>
        </div>
    </form>
</div>

<div class="client-hotline2">
    <a href="tel:4008882006" class="hotline">
        <g:img class="hotlineIcon" dir="images" file="hotline-icon.png"/>
        <span class="city-hotline">4008882006</span>
    </a>
</div>

%{--提示信息和验证--}%
<div class="message-box" style="top: 20%;">
    <div class="helpMsg hide"></div>
    <g:if test="${flash.message}">
        <div class="message" role="status">
            ${flash.message}
        </div>
    </g:if>
</div>

<script>
    $(function () {
        function getDistrict() {
            $.ajax({
                type: "POST",
                url: "/wechatOpportunity/wxGetDistrictByCity",
                data: {
                    city: $("#city").val(),
                },

                success: function (data) {
                    var dataList = data.districtList;
                    var option;
                    if (data.status == "success") {
                        $('#district').html("");
                        for (var i = 0; i < dataList.length; i++) {
                            option = '<option value="' + dataList[i] + '">' + dataList[i] + '</option>';
                            $("#district").append(option)
                        }
                    }
                },
                error: function () {
                    helpMessage("区县获取失败，请稍后重试");
                }
            });
        }

        getDistrict();
        // 动态获取县区
        $("#city").change(function () {
            getDistrict();
        });

        $("#wxcreateStep1Btn").click(function () {

            var district = $("#district").val();
            if (!district) {
                helpMessage("请输入所属区县");
                return;
            }

            var projectName = $("#projectName").val();
            if (!projectName) {
                helpMessage("请输入小区名称");
                return;
            }

            $("#wxCreate2Form1").submit();
        });
        function helpMessage(message) {
            $(".helpMsg").text(message).fadeIn(200);
            setTimeout(function () {
                $(".helpMsg").fadeOut(200);
            }, 2000);
        }
    })
</script>
</body>
</html>
